package test2

import (
	"fmt"
)

type Animal struct {
	Name string
}

func (a Animal) Call() string {
	return "我高兴地叫出了声音"
}

func (a Animal) FavorFood() string {
	return "我怎么啥都喜欢吃"
}

func (a Animal) GetName() string {
	return a.Name
}

type Dog struct {
	Animal
}
func (d Dog) Call() string {
	return "汪汪！"
}

type Cat struct {
	*Animal
}

func Test1() {
	animal := Animal{"中华田园犬"}
	dog := Dog{
		animal,
	}
	fmt.Println(dog.Call())
	fmt.Println(dog.Animal.Call())
	fmt.Println(animal.Name)
	jumao := Cat{
		&Animal{Name: "张云雷的橘猫"},
	}
	fmt.Println(jumao.Name)
}